Repository navigation
fix(mcp): reduce describe_source timeouts by using rollup tables for map key discovery - #2426
Conversation
…map key discovery Pass metadataMVs and dateRange to getMapKeys in Stage 2 so it queries the rollup table instead of scanning millions of rows in the main table. Also thread AbortSignal through getMapValues so fallback queries cancel when the 10s wall-clock timeout fires.
🦋 Changeset detectedLatest commit: b4d6f7a The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
E2E Test Results✅ All tests passed • 197 passed • 3 skipped • 1353s
Tests ran across 4 shards in parallel. |
Greptile SummaryThis PR fixes
Confidence Score: 4/5Safe to merge for the common case, but a timeout during the newly-enabled rollup query in Stage 2 will cache an empty key list for the entire aligned time window, causing all subsequent describe calls to silently return no map attribute keys until the process restarts. The rollup-path closure in The rollup Important Files Changed
Sequence DiagramsequenceDiagram
participant C as MCP Caller
participant DS as describeSource
participant GK as getMapKeys
participant RU as Rollup Table
participant MT as Main Table
C->>DS: clickstack_describe_source
DS->>DS: compute metadataMVs + dateRange (hoisted above Stage 2)
DS->>DS: Stage 1 - getColumns()
DS->>GK: getMapKeys with metadataMVs + dateRange + signal
note over GK: Check persistent MetadataCache
alt rollup path available
GK->>RU: SELECT Key FROM keyRollupTable WHERE ColumnIdentifier AND Timestamp range
RU-->>GK: keys
GK-->>DS: keys
else rollup empty or unavailable
GK->>MT: full table scan
MT-->>GK: keys
GK-->>DS: keys
end
DS->>DS: Stage 3 - getAllKeyValues LC columns
DS->>DS: Stage 4 - getAllKeyValues map attribute values
DS-->>C: schema + mapAttributeKeys + values
Reviews (3): Last reviewed commit: "Merge branch 'main' into claude/fix-desc..." | Re-trigger Greptile |
Summary
clickstack_describe_sourcecan time out (10s wall-clock limit) when discovering map attribute keys on large tables. Stage 2 (map key discovery) was always falling back to a full main-table scan—up to 3M rows per Map column—even when rollup tables were available, becausemetadataMVsanddateRangeweren't computed yet at that point in the pipeline.This hoists the rollup config and date range above Stage 2 so
getMapKeyscan use the fast rollup path. On the traces table in large environments this reduces Stage 2 from ~5-10s to <1s, keeping the full describe call well within the 10s budget.Additionally,
getMapValuesnow accepts anAbortSignalso that any per-key fallback queries are cancelled when the timeout fires, rather than running to completion against ClickHouse after the caller has already given up.